package demo.gui;

import java.awt.*;
import java.awt.event.*;

public class MyMenu {

	private Frame f;
	private MenuBar mb;
	private Menu m1, m2, m3, m4;
	private MenuItem mi1, mi2, mi3, mi4;
	private Label lab;

	public MyMenu() {
		init();
	}

	private void init() {
		f = new Frame("�˵�");
		f.setBounds(600, 500, 250, 120);
		f.setLayout(new FlowLayout());
		lab = new Label("Ȱ��ֱ���˳�");
		mb = new MenuBar();
		m1 = new Menu("ѡһ����");
		m2 = new Menu("��Ҳ��ѡ");
		m3 = new Menu("�⻹��ѡ");
		m4 = new Menu("զ����ѡ");
		mi1 = new MenuItem("�˳�");
		mi2 = new MenuItem("�����˳�");
		mi3 = new MenuItem("���˳���");
		mi4 = new MenuItem("����ɵ��");
		f.add(lab);
		f.setMenuBar(mb);
		mb.add(m1);
		m1.add(mi1);
		m1.add(m2);
		m2.add(mi2);
		m2.add(m3);
		m3.add(mi3);
		m3.add(m4);
		m4.add(mi4);
		addEvent();
		f.setVisible(true);
	}

	private void addEvent() {
		add(mi1);
		add(mi2);
		add(mi3);
		add(mi4);
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}

	private void add(MenuItem m) {
		m.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
	}

	public static void main(String[] args) {
		new MyMenu();
	}

}
